//
//  TrackitGlobal.h
//  Trackit
//
//  Created by yaodaobin on 2017/4/2.
//  Copyright © 2017年 yaodaobin. All rights reserved.
//

#if (ADHOC > 0 || DEBUG > 0)
#	define DLog(fmt, ...) NSLog((@"%s #%d " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#	define DLog(...)
#endif

//版本比较
#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

// weakself
#pragma mark - weakSelf
#define kWeakSelf __weak typeof (self) weakSelf = self;
#define kStrongSelf __strong __typeof(&*weakSelf)strongSelf = weakSelf;
#define kWeakObj(obj)  __weak typeof(obj) weakObj = obj;

#define SuppressPerformSelectorLeakWarning(Stuff) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
Stuff; \
_Pragma("clang diagnostic pop") \
} while (0)

#define kThisApp @"592318714"

//http://iphonedevsdk.com/forum/business-legal-app-store/115711-rate-app-link-p2.html
//works for most ios version except IOS7.0 (goes to main page), it's fine
#define kRatingUrl [NSString stringWithFormat: @"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=%@&pageNumber=0&sortOrdering=2&type=Purple+Software&mt=8", kThisApp]

#define kTextViewPadding            8.0

#define NOTIFICATION_REFRESH_INTERVAL 300

#pragma mark - 字符串

//Splash
#define kSplashCachePathSavingKey @"kSplashCachePathSavingKey"
#define kSplashFolderName @"splash"

// frame
#pragma mark - frame

#define SYSTEM_NAVIGATION_HEIGHT 44
#define GLOBAL_BOTTOM_BAR_HEIGHT 44
#define UPLOAD_IMAGE_MIN_SIZE 160.0
#define TOPIC_PER_PAGE_COUNT 10
#define WEB_TOPIC_PER_PAGE_COUNT 20
#define PHONE_KEYBOARD_HEIGHT 216.0f
#define AVATAR_NORMAL_SIZE 35.0f
#define NORMAL_TEXT_FIELD_HEIGHT 44.0f

//loction time
#define LOCATIONTIME 1800
#define O2OLOCATIONTIME  1800

#define SUPPRESS_PERFORMSELECTOR_LEAK_WARNING(Stuff) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
Stuff; \
_Pragma("clang diagnostic pop") \


// statusbar height
#define kStatusbarHeight 20
// navbar height
#define kNavbarHeight SYSTEM_NAVIGATION_HEIGHT
// screen size      (0,0)(320,480)
#define kScreenFrame      [[UIScreen mainScreen] bounds]
// Application size (0,20)(320,460)
#define kApplicationFrame [UIScreen mainScreen].applicationFrame
// screen width
#define kScreenWidth     [[UIScreen mainScreen] bounds].size.width
// screen height
#define kScreenHeight    [[UIScreen mainScreen] bounds].size.height

// tabbar height
#define kTabBarHeight   50

// 浏览图片的最大尺寸
#define kShowImageMaxSize  2048
//缓存路径
#define APPCachePath @"com.hackemist.SDWebImageCache.default"

#define CLASS(className) [NSClassFromString(className) class]


#pragma mark - color

#define RGBA_COLOR(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
#define HEX_COLOR(h,a) [UIColor colorWithHex:h alpha:a]

#define kMainColor 0xff7e6d

#define COLOR_MAIN HEX_COLOR(kMainColor, 1)

#define COLOR_NORMAL_TEXT RGBA_COLOR(133, 133, 133, 1)
#define COLOR_NORMAL_SUB_INFOR RGBA_COLOR(102, 102, 102, 1)
#define COLOR_BUTTON_GRAY RGBA_COLOR(210, 210, 210, 1)
#define COLOR_LIGHT_GRAY RGBA_COLOR(245, 245, 245, 1)
#define COLOR_PINK RGBA_COLOR(255, 97, 145, 1)

#define COLOR_21_POINT RGBA_COLOR(216, 68, 58, 1.0)

#define COLOR_BUTTON_TITLE_PINK HEX_COLOR(0xFE87A5,1)
#define COLOR_BUTTON_TITLE_HIGHLIGHT_PINK RGBA_COLOR(255, 179, 202, 1)
#define COLOR_BUTTON_TITLE_DISABLE_YELLOW RGBA_COLOR(255, 207, 0, 1)

#define COLOR_YELLOW RGBA_COLOR(255, 204, 0, 1)
#define COLOR_PINK_PRESSED RGBA_COLOR(247, 43, 104, 1)
#define COLOR_NORMAL_BACKGROUND RGBA_COLOR(255, 255, 255, 1)
#define COLOR_DEEP_BACKGROUND RGBA_COLOR(240, 240, 240, 1)

#define COLOR_CELL_LINE HEX_COLOR(0xe7e7e7, 1)

#define COLOR_LOGINVIEW HEX_COLOR(0xF77E69, 1)
#define COLOR_MAINFONT_VERSION3_1_4  HEX_COLOR(0xff8282,1);

#define COLOR_LOGINFONT HEX_COLOR(0xFFFFFF, .6)

#define COLOR_CARD_BACKGROUND RGBA_COLOR(240, 240, 240, 1)

#define COLOR_NAV_TITLE RGBA_COLOR(0x33, 0x33, 0x33, 1)
#define COLOR_NAV_BACKGROUND RGBA_COLOR(251, 251, 251, 1)

#define COLOR_DESC_INFOR RGBA_COLOR(96, 96, 96, 1)

#define COLOR_MONEY RGBA_COLOR(255, 62, 137, 1.0f)

#define COLOR_POST_BACKGROUND RGBA_COLOR(219, 219, 219, 1)
#define COLOR_POST_FIELD_BORDER RGBA_COLOR(182, 182, 182, 1)
#define COLOR_POST_FIELD_Text RGBA_COLOR(183, 183, 183, 1)

#ifdef DEBUG
#define NSLog(format, ...) printf("\n[%s] %s [第%d行] %s\n", __TIME__, __FUNCTION__, __LINE__, [[NSString stringWithFormat:format, ## __VA_ARGS__] UTF8String]);
#else
#define NSLog(format, ...)
#endif
#define COLOR_Yuer_Comment_UserName  HEX_COLOR(0x343434, 1.0)
#define COLOR_Yuer_Content           HEX_COLOR(0x787878, 1.0)

#define VERSION_8_0_LATER ([[UIDevice currentDevice].systemVersion doubleValue] >= 8.0f)

#define iPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone6P ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)

#define COLOR_RECIPE_BACKGROUND RGBA_COLOR(253, 250, 241, 1)
#define COLOR_RECIPE_SECTION_BACKGROUND RGBA_COLOR(242, 231, 209, 1)
#define COLOR_RECIPE_LINE RGBA_COLOR(234, 214, 195, 1.0);

#define COLOR_SALE_BACKGROUND [UIColor colorWithPatternImage:[UIImage imageNamed:@"background_partten"]]


#pragma mark - NSNotification
#define kProductName   @"草畜"
#define NoLogINdex_params  @"index_params"

#define kNavigationTintColor COLOR_MAIN

#define kMainBackBtnImgName @"back"

#define kIsIOS9 [[UIDevice currentDevice].systemVersion doubleValue] > 8.9

